package com.mylib.libcore.glide;

import android.app.Activity;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.mylib.libcore.R;
import com.lzy.imagepicker.loader.ImageLoader;


import java.io.File;

/**
 * 用于图片选择器
 * 三方库依赖
 * github地址：https://github.com/jeasonlzy/ImagePicker
 */
public class GlideImageLoader implements ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {

        GlideApp.with(activity)
                .load(Uri.fromFile(new File(path)))
                .placeholder(R.drawable.store_album_choose)
                .error(R.drawable.store_album_choose)
                .diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
                .into(imageView);
    }

    @Override
    public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
        GlideApp.with(activity)
                .load(Uri.fromFile(new File(path)))
                .placeholder(R.drawable.store_album_choose)
                .error(R.drawable.store_album_choose)
                .diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
                .into(imageView);
    }

    @Override
    public void clearMemoryCache() {
        //这里是清除缓存的方法,根据需要自己实现
    }
}
